package com.example.administrator.smartbutler.view;

import android.app.Dialog;
import android.content.Context;
import android.support.annotation.NonNull;
import android.support.annotation.StyleRes;
import android.view.Gravity;
import android.view.Window;
import android.view.WindowManager;
import android.widget.GridView;

import com.example.administrator.smartbutler.R;

/**
 * 项目名:SmartButler
 * 包名:com.example.administrator.smartbutler.view
 * 文件名：CustomDialog
 * 创建者：justin
 * Created by Administrator on 2018/1/30.
 * 描述：TODO
 */

public class CustomDialog extends Dialog {


    //定义模板
    public CustomDialog(Context context, int layout, int style) {

        /**
         *
         */

        this(context, WindowManager.LayoutParams.WRAP_CONTENT, WindowManager.LayoutParams.WRAP_CONTENT, layout, style, Gravity.CENTER);
    }

    //定义属性
    public CustomDialog(Context context, int width, int height, int layout, int style, int gravity, int anim) {

        super(context, style);

        //设置属性
        setContentView(layout);

        Window window = getWindow(); //窗口界面

        WindowManager.LayoutParams layoutParams = window.getAttributes(); //布局参数

        layoutParams.width = width;
        layoutParams.height = width;

        layoutParams.gravity = gravity;//方向

        window.setAttributes(layoutParams);

        window.setWindowAnimations(anim);//动画

    }

    //实例
    public CustomDialog(Context context, int width, int height, int layout, int style, int gravity){
        this(context,width,height,layout,style,gravity,R.style.pop_anim_style);
    }

}
